<template>
  <div>
    <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
      <el-form :inline="true" :model="filters" @submit.native.prevent>
        <el-form-item width="1000%">
          <el-input
            clearable
            :span="18"
            type="textarea"
            :rows="5"
            style="width:1000px"
            v-model="mytext"
            width="80%"
            prefix-icon="el-icon-search"
            placeholder='请输入密文json,格式为{"resContent":"密文"}'
            @keyup.enter.native="RSADecrypt"
          ></el-input>
        </el-form-item>
        <br />

        <a class="color-red"
          >注:&nbsp &nbsp提供广州政采代加密数据解密<br />
          &nbsp &nbsp &nbsp &nbsp1 数据格式必须为{"resContent":"密文"}<br />
          &nbsp &nbsp &nbsp
          &nbsp2只解密resContent对应的value值，其他键值对将你不会返回结果</a
        >

        <br />

        <br />
        <el-form-item>
          <el-button type="primary" @click="RSADecrypt">RSA解密</el-button>
        </el-form-item>
      </el-form>
    </el-col>

    <div id="decryptDate" v-html="result"></div>
  </div>
</template>

<script>
import { getJavaDecrypt } from "../../../../api/api";
export default {
  result: "",

  methods: {
    RSADecrypt: function() {
      let self = this;

      let params = { content: this.mytext };

      let headers = {
        Authorization: "Token " + JSON.parse(sessionStorage.getItem("token")),
      };
      getJavaDecrypt(headers, params).then((res) => {
        let { msg, code, data } = res;
        if (code === "999999") {
          this.result = data.data;

          this.$confirm("提示", {
            title: "解密结果",
            message: this.result,
            showCancelButton: false,
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "success",
          })
            .then(() => {})
            .catch(() => {});
        } else {
          self.$message.error({
            message: msg,
            center: true,
          });
        }
      });
    },
  },
  mounted() {
    this.$nextTick(function() {
      //this.RSADecrypt();
    });
  },
};
</script>
<style scoped>
h1 {
  color: red;
}

.color-red {
  color: red;
  border: 1px solid #e8e8e8;
  padding: 0px 6px 0 9px;
  margin-right: 23px;
}
</style>
